<?php include "htmlBase/header.php"; ?>

<?php
include_once 'Entidades/EntidadeBase.php';
include_once 'Entidades/Responsavel.php';
$servicoResponsavel = new Responsavel();
$Responsavel = isset($_GET["Id"]) ? $servicoResponsavel->ObterPorId($_GET["Id"]) : new Responsavel();

require 'Entidades/Cras.php';
$servicoCras = new Cras();

include_once 'Controles/ComboBox.php';
?>

<script>
    
    $(document).ready(
    function () 
    { 
			
        $("input[name = 'DataNascimento']").datepicker(
        {
            changeMonth: true,
            changeYear: true
        });
        
        $("input[name = 'DataCadastro']").datepicker(
        {
            changeMonth: true,
            changeYear: true
        });
        

        $("input[name = 'Salario']").spinner(
        {
            min: 0,
            max: 999999,
            step: 100,
            start: 0,
            numberFormat: "n"
        });

    
    });
    
    function Validar_Form(form)
    {
<?php
{
    $Responsavel->getJavaScriptCamposObrigatoriosInput();
}
?>
           
        return true;
    }
   
</script>

<div class="page secondary">
    <div class="page-header">
        <div class="page-header-content">
            <h1>Responsável <small>(Cadastro)</small></h1>
            <?php
            if ($Responsavel->Id == 0)
            {
                ?>
                <a href="ResponsavelPesquisa.php" class="back-button big page-back"></a>
                <?php
            } else
            {
                ?>
                <a href="ResponsavelPainel.php?Id=<?php echo $Responsavel->Id; ?> "class="back-button big page-back"></a>
                <?php
            }
            ?>
        </div>
        <div class="progress-bar" align="rigth">
            <div class="bar bg-color-blue" style="width: 75%"></div>
        </div>
    </div>
    <br/>
    <div class="page secondary">
        <div class="page-region">
            <div class="page-region-content">

                <form action="ResponsavelDados.php" method="POST" onsubmit="return Validar_Form(this)">
                    <input type="hidden" class="with-helper" name="Id" value="<?php echo $Responsavel->Id; ?>"/>

                    <div class="grid">
                        <div class="row">
                            <div class="span2">
                                <div class="input-control text">
                                    <h4>CPF</h4>
                                    <input type="text" class="with-helper" placeholder="CPF" name="CPF" value="<?php echo $Responsavel->CPF; ?>" maxlength="15"/>
                                </div>
                            </div>

                            <div class="span5">
                                <div class="input-control text">
                                    <h4>Nome</h4>
                                    <input type="text" class="with-helper" placeholder="Nome" name="Nome" value="<?php echo $Responsavel->Nome; ?>" maxlength="60"/>
                                </div>
                            </div>

                            <div class="span3">
                                <div class="input-control text">
                                    <h4>Data de Nascimento</h4>
                                    <input type="text" placeholder="Data de Nascimento" name="DataNascimento" value="<?php echo $Responsavel->DataNascimento; ?>" style="text-align: right;"/>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="span2">
                                <div class="input-control text">
                                    <h4>RG</h4>
                                    <input type="text" class="with-helper" placeholder="RG" name="RG" value="<?php echo $Responsavel->RG; ?>" maxlength="15"/>
                                </div>
                            </div>

                            <div class="span3">
                                <div class="input-control text">
                                    <h4>Grau de Instrução</h4>
                                    <?php ComboBox("GrauDeInstrucao", "id_GrauDeInstrucao", $Responsavel->id_GrauDeInstrucao); ?>
                                </div>
                            </div>

                            <div class="span2">
                                <div class="input-control text">
                                    <h4>NIS</h4>
                                    <input type="text" class="with-helper" placeholder="NIS" name="NIS" value="<?php echo $Responsavel->NIS; ?>" maxlength="20"/>
                                </div>
                            </div>

                            <div class="span3">
                                <div class="input-control text">
                                    <h4>Naturalidade</h4>
                                    <?php ComboBox("Naturalidade", "id_Naturalidade", $Responsavel->id_Naturalidade); ?>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="span5">
                                <div class="input-control text">
                                    <h4>Endereço</h4>
                                    <input type="text" class="with-helper" placeholder="Endereço" name="Endereco" value="<?php echo $Responsavel->Endereco; ?>" maxlength="60"/>
                                </div>
                            </div>
                            <div class="span2">
                                <div class="input-control text">
                                    <h4>Numero</h4>
                                    <input type="text" class="with-helper" placeholder="Numero" name="EnderecoNumero" value="<?php echo $Responsavel->EnderecoNumero; ?>" maxlength="60"/>
                                </div>
                            </div>

                            <div class="span3">
                                <div class="input-control text">
                                    <h4>Bairro</h4>
                                    <input type="text" class="with-helper" placeholder="Bairro" name="Bairro" value="<?php echo $Responsavel->Bairro; ?>" maxlength="60"/>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="span2">
                                <div class="input-control text">
                                    <h4>Telefone</h4>
                                    <input type="text" class="with-helper" placeholder="Telefone" name="Telefone" value="<?php echo $Responsavel->Telefone; ?>" maxlength="60"/>
                                </div>
                            </div>
                            <div class="span6">
                                <div class="input-control text">
                                    <h4>Cras</h4>
                                    <?php ComboBox("Cras", "id_Cras", $Responsavel->id_Cras); ?>
                                </div>
                            </div>

                            <div class="span2">
                                <div class="input-control text">
                                    <h4>Forma de Acesso</h4>
                                    <input type="text" class="with-helper" placeholder="F. de Acesso" name="FormaDeAcesso" value="<?php echo $Responsavel->FormaDeAcesso; ?>" maxlength="60"/>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="span7">
                                <div class="input-control text">
                                    <h4>Ocupação</h4>
                                    <input type="text" class="with-helper" placeholder="Ocupação" name="Ocupacao" value="<?php echo $Responsavel->Ocupacao; ?>" maxlength="60"/>
                                </div>
                            </div>
                            <div class="span3">
                                <div class="input-control text">
                                    <h4>Salário</h4>
                                    <input type="text" class="with-helper" placeholder="Salario" name="Salario" value="<?php echo $Responsavel->Salario; ?>" maxlength="60"/>
                                </div>
                            </div>
                        </div>

                    </div>

                    <br/>

                    <div class="input-control" style="margin-left: auto; margin-right: auto;">
                        <button class="standart default" type="submit">Salvar</button>
                        <a href="ResponsavelCadastro.php" class="button standart">Novo</a>
                        <?php
                        if ($Responsavel->Id != 0)
                        {
                            ?>
                            <a href="ResponsavelCadastro.php?Id=<?php echo $Responsavel->Id; ?>" class="button standart">Cancelar</a>
                            <a href="ResponsavelPainel.php?Id=<?php echo $Responsavel->Id; ?>" class="button standart bg-color-lighten" style="float: right">Voltar</a>
                            <?php
                        } else
                        {
                            ?>
                            <a href="ResponsavelPesquisa.php" class="button standart bg-color-lighten" style="float: right">Lista</a>
                            <?php
                        }
                        ?>
                    </div>
                </form>
            </div>


        </div>
    </div>
</div>

<?php include "htmlBase/footer.php"; ?>